import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;

/*
 ID: ning yusui
 LANG: JAVA
 TASK: preface
 */

public class preface {
	// "M" "CM" "D" "CD" "C" "XC" "L" "XL" "X" "IX" "V" "IV" "I"
	static final int weights[] = { 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9,
			5, 4, 1 };
	static final String chars = "IVXLCDM";
	static final int firstCharIndex[] = { 6, 4, 5, 4, 4, 2, 3, 2, 2, 0, 1, 0, 0 };
	static final int secondCharIndex[] = { -1, 6, -1, 5, -1, 4, -1, 3, -1, 2,
			-1, 1, -1 };
	static int counts[] = { 0, 0, 0, 0, 0, 0, 0 };

	static void count(int num) {
		for (int i = 0; i < 13; i++) {
			while ((num - weights[i]) >= 0) {
				num -= weights[i];
				counts[firstCharIndex[i]]++;
				if (secondCharIndex[i] >= 0)
					counts[secondCharIndex[i]]++;
			}
		}
	}

	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(new File("preface.in"));
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
				"preface.out")));
		int n = in.nextInt();
		for (int i = 1; i <= n; i++) {
			count(i);
		}
		for (int i = 0; i < counts.length; i++) {
			if (counts[i] > 0) {
				out.println(chars.charAt(i) + " " + counts[i]);
			}
		}
		out.close();
		System.exit(0);
	}
}
